﻿using AgencyManagerSystem.Common;
using AgencyManagerSystem.DataFetcher;
using Dapper.Contrib.Extensions;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;

namespace AgencyManagerSystem.DataUpdater
{
    public abstract class StatusUpdater<T>:BaseUpdater<T> where T : StatusModel
    {
        public StatusUpdater(BaseFetcher<T> fetcher):base(fetcher)
        {

        }
        public virtual bool Close(int autoId,string reason,out string message)
        {

            var model = baseFetcher.Get(autoId);
            if (model == null)
            {
                message = "找不到对象";
                return false;
            }
            model.Status = (int)StatusCode.Closed;
            model.CloseReason = reason;
            return Save(model,out message) == 0;
        }
    }
}
